<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改漫画名称 ')" />
    <!--select 下拉框-->
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-name-edit" th:object="${mhName}">
            <input name="id" th:field="*{id}" type="hidden">

            <div class="col-sm-12">

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">漫画名称：</label>
                        <div class="col-sm-8">
                            <input name="name" class="form-control" th:field="*{name}" type="text" required>
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">漫画类型：</label>
                        <div class="col-sm-8">
                            <select name="typeName" th:field="*{typeName}" class="form-control">
                                <option th:value="${mhName.typeId+','+mhName.typeName}" th:text="${mhName.typeName}"></option>
                                <option th:each="dict : ${@dict.getType('manhua')}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictCode+','+dict.dictLabel}"></option>
                            </select>

                        </div>
                    </div>
                </div>

                <!--
                <div class="form-group">
                <label class="col-sm-3 control-label">漫画类型名称：</label>
                <div class="col-sm-8">
                    <input name="typeName" class="form-control" type="text">
                </div>
                </div>
                -->

            </div>

            <div class="col-sm-12">

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">最新篇章：</label>
                        <div class="col-sm-8">
                            <input name="newZhang" th:field="*{newZhang}" class="form-control" type="text">
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">漫画作者：</label>
                        <div class="col-sm-8">
                            <input name="author"  th:field="*{author}" class="form-control" type="text">
                        </div>
                    </div>
                </div>


            </div>

            <div class="col-sm-12">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">漫画国家：</label>
                        <div class="col-sm-8">
                            <select name="countriesName" th:field="*{countriesName}"  class="form-control">
                                <option value=" "> </option>
                                <option th:each="dict : ${@dict.getType('guojia')}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictCode+','+dict.dictLabel}"></option>
                            </select>

                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control" style="margin: 0px 10.6625px 0px 0px; width: 465px; height: 272px;">[[*{remark}]]</textarea>
                </div>
            </div>

            <!--<div class="form-group">
                <label class="col-sm-3 control-label is-required">漫画类型，存放的是字典数据表的id：</label>
                <div class="col-sm-8">
                    <input name="typeId" th:field="*{typeId}" class="form-control" type="text" required>
                </div>
            </div>-->


           <!-- <div class="form-group">
                <label class="col-sm-3 control-label">点赞：</label>
                <div class="col-sm-8">
                    <input name="give" th:field="*{give}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收藏：</label>
                <div class="col-sm-8">
                    <input name="collect" th:field="*{collect}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">评论：</label>
                <div class="col-sm-8">
                    <input name="comment" th:field="*{comment}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">喜欢数量：</label>
                <div class="col-sm-8">
                    <input name="fond" th:field="*{fond}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">阅读数量：</label>
                <div class="col-sm-8">
                    <input name="read" th:field="*{read}" class="form-control" type="text">
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <!--select 下拉框-->
    <th:block th:include="include :: select2-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "manhua/name";
        let requiredStr = "不能为空";
        $("#form-name-edit").validate({
            rules: {
                name: {
                    maxlength: 255,
                    required: true,
                    remote: {
                        url: prefix + "/list",
                        type: "post",
                        dataType: "json",
                        data: {
                            "name": function () {
                                return $.common.trim($("input[name='name']").val());
                            }
                        },
                        success: function (data, type) {
                            if(data.rows.length != web_status.SUCCESS){
                                $.modal.alertWarning('漫画名称已存在!');
                            }
                        }
                    }
                },
                typeName: {
                    maxlength: 255,
                    required: true,
                },
                newZhang: {
                    maxlength: 500,
                    required: true
                },
                author: {
                    maxlength: 255,
                    required: true
                },
                remark: {
                    maxlength: 500,
                    required: true
                },

            },
            messages: {
                name: {
                    maxlength: "最多输入255个字符.",
                    required: requiredStr,
                    remote:"漫画名称已存在",
                },
                typeName: {
                    maxlength: "最多输入255个字符.",
                    required: requiredStr,
                },
                newZhang: {
                    maxlength: "最多输入500个字符.",
                    required: requiredStr
                },
                author: {
                    maxlength: "最多输入255个字符.",
                    required: requiredStr
                },
                remark: {
                    maxlength: "最多输入500个字符.",
                    required: requiredStr
                }

            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-name-edit').serialize());
            }
        }
    </script>
</body>
</html>